from pandas.plotting import scatter_matrix
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np

csv_file_name = '南玻A.csv'
# 可视化展示:
stock_data = pd.read_csv(csv_file_name, encoding='gb2312')#文件读取
stock_data = stock_data.sort_values(by=["日期"], ascending=[True], inplace=False)#
stock_name = stock_data["名称"][0]
row_count = stock_data.shape[0]
# 支持中文
plt.rcParams['font.sans-serif'] = ['SimHei']  # 用来正常显示中文标签
plt.rcParams['axes.unicode_minus'] = False  # 用来正常显示负号
stock_data_recent =stock_data[row_count-365:row_count]
scatter_matrix(stock_data_recent[['收盘价','换手率','成交量','总市值']],alpha=0.5,c='b',marker='.')
cov=np.corrcoef(stock_data_recent[['收盘价','换手率','成交量','总市值']].T)
print(cov)
img=plt.matshow(cov)
plt.colorbar(img,ticks=[-1,0,1])
plt.show()

